package bm.com.ai.server.LLModel.config;

import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
public class QwenModelConfiguration {

    @Value("${langchain4j.community.dashscope.chat-model.model-name:qwen-plus}")
    private String modelName;

    @Value("${langchain4j.community.dashscope.chat-model.api-key:sk-6fd5a25ac91c4b76aa0c236a31bb4cf2}")
    private String key;

    @Value("${ai.qwen.enabled:true}")
    private boolean enabled = true;

    @Value("${ai.qwen.temperature:0.7}")
    private double temperature;

    @Value("${ai.qwen.max-tokens:2048}")
    private int maxTokens;

    @Value("${ai.qwen.top-p:0.95}")
    private double topP;

    @Bean
    public Generation generation() {
        Generation generation = new Generation();
        return generation;
    }

    @Bean
    @ConditionalOnMissingBean(GenerationParam.class)
    public GenerationParam generationParam() {
        return GenerationParam.builder()
                .model(modelName)
                .build();
    }
}